package cn.tannn.ops.pwd.dao;

import cn.tannn.jdevelops.jpa.repository.JpaBasicsRepository;
import cn.tannn.ops.pwd.entity.KeePassEntity;
import cn.tannn.ops.pwd.enums.KeePassStatus;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * 密码管理器
 *
 * @author tnnn
 * @version V1.0
 * @date 2023-02-02 16:30
 */
public interface KeePassDao extends JpaBasicsRepository<KeePassEntity, Long> {

    /**
     * 更新状态
     *
     * @param id     id
     * @param status KeePassStatus
     */
    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query("update KeePassEntity sw set sw.status = :status where  sw.id in (:id) ")
    void changeStatus(@Param("id") Long id, @Param("status") KeePassStatus status);
}
